-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Travelperk Guard #1132
feat: Travelperk Guard #1132
Conversation
WalkthroughThis pull request introduces a new Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
src/app/core/guard/travelperk-token.guard.ts (2)
1-9
: Consider a dedicated import grouping for improved readability.Currently, imports for Angular modules, RxJS, and application-specific services appear in a single block. It's sometimes beneficial to group imports by domain (e.g., Angular core, external libraries, internal services) to simplify scanning. This is purely optional and doesn't affect functionality.
32-49
: Validate error status check and rethrow approach.
- Currently, only 400 is handled as an expired connection scenario. Consider whether there are other relevant status codes (e.g., 401 or 403) that should trigger the same re-authentication flow.
- The guard rethrows the error after handling the 400 status scenario. Make sure any upstream error handler or route error resolution is also prepared to handle it.
src/app/core/guard/travelperk-token.guard.spec.ts (2)
7-7
: Remove trailing spaces.Static analysis reports trailing spaces on this line. Removing them keeps the codebase clean and consistent with style guidelines.
7c7 - const executeGuard: CanActivateFn = (...guardParameters) => + const executeGuard: CanActivateFn = (...guardParameters) =>🧰 Tools
🪛 eslint
[error] 7-7: Trailing spaces not allowed.
(no-trailing-spaces)
🪛 GitHub Check: lint
[failure] 7-7:
Trailing spaces not allowed
14-16
: Add more test coverage for guard logic.The current test only verifies that the guard is created. Consider adding tests that validate:
- Behavior when workspace ID is missing.
- Behavior when a 400 error is thrown by travelperkService.
- Behavior for successful connection.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/app/core/guard/travelperk-token.guard.spec.ts
(1 hunks)src/app/core/guard/travelperk-token.guard.ts
(1 hunks)src/app/integrations/travelperk/travelperk-onboarding/travelperk-onboarding-routing.module.ts
(2 hunks)src/app/integrations/travelperk/travelperk-routing.module.ts
(2 hunks)
🧰 Additional context used
🪛 eslint
src/app/core/guard/travelperk-token.guard.spec.ts
[error] 7-7: Trailing spaces not allowed.
(no-trailing-spaces)
🪛 GitHub Check: lint
src/app/core/guard/travelperk-token.guard.spec.ts
[failure] 7-7:
Trailing spaces not allowed
🔇 Additional comments (8)
src/app/core/guard/travelperk-token.guard.ts (2)
14-20
: Constructor injection looks good, but verify if all services are needed.
You’re injecting four different services: travelperkService, router, toastService, and workspaceService. Ensure that each of these is necessary for the logic in this guard. If any are not used, consider removing them to maintain minimal dependencies.
21-31
: Ensure proper error handling when no workspace ID is found.
The guard redirects the user to "workspaces" if no workspace ID is found, then throws an error. This is viable; however, if you intend the user experience to remain on the "workspaces" page, verify that the thrown error doesn’t get logged or displayed incorrectly in the caller. If your global error handler or any surrounding subscriber is set to handle thrown errors, ensure that user-facing logs or alerts are comprehensible.
src/app/integrations/travelperk/travelperk-routing.module.ts (2)
4-4
: Import statement is correct.
Good job importing the guard from the correct path. No action needed.
17-18
: Confirm that applying canActivate to 'main' route meets intended user flow.
Now that 'main' is guarded, ensure other routes or flows do not inadvertently bypass this check. If certain flows or modules also require protection, confirm that they have the guard in place or do not need to be guarded.
src/app/integrations/travelperk/travelperk-onboarding/travelperk-onboarding-routing.module.ts (4)
8-8
: Guard import suits the architecture.
Using the same guard for both main and onboarding routing is consistent, keeping the logic centralized. No additional changes required.
21-22
: Enforce guard for Payment Profile Settings route.
This ensures a user cannot configure Payment Profile Settings for TravelPerk without valid credentials. Good approach.
26-27
: Enforce guard for Advanced Settings route.
Likewise, restricting access helps maintain consistent security across advanced TravelPerk settings.
31-32
: Enforce guard for Done route.
Even the last step of onboarding is now protected. Ensure user flow is correct if they’re forced to re-authenticate or connect again at the final step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/app/core/guard/travelperk-token.guard.spec.ts (1)
1-1
: Remove trailing spaces.The line contains trailing spaces which should be removed.
- +🧰 Tools
🪛 eslint
[error] 1-1: Trailing spaces not allowed.
(no-trailing-spaces)
🪛 GitHub Check: lint
[failure] 1-1:
Trailing spaces not allowed
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/app/core/guard/travelperk-token.guard.spec.ts
(1 hunks)
🧰 Additional context used
🪛 eslint
src/app/core/guard/travelperk-token.guard.spec.ts
[error] 1-1: Trailing spaces not allowed.
(no-trailing-spaces)
🪛 GitHub Check: lint
src/app/core/guard/travelperk-token.guard.spec.ts
[failure] 1-1:
Trailing spaces not allowed
@@ -0,0 +1 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Implement test suite for TravelperkTokenGuard.
The test file is empty, but it should contain comprehensive test cases for the TravelperkTokenGuard to ensure proper route protection. The guard needs testing for:
- Workspace ID validation
- TravelPerk connection status checks
- Different routing scenarios (success, redirects to workspace/onboarding)
Would you like me to help generate a complete test suite? Here's what I propose to include:
- Test setup with necessary TestBed configuration
- Mock services for workspace and TravelPerk connection
- Test cases for:
- Valid workspace ID and active connection
- Missing workspace ID
- Inactive/expired TravelPerk connection
- Various routing scenarios
🧰 Tools
🪛 eslint
[error] 1-1: Trailing spaces not allowed.
(no-trailing-spaces)
🪛 GitHub Check: lint
[failure] 1-1:
Trailing spaces not allowed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/app/core/services/travelperk/travelperk.service.ts (1)
33-40
: Consider making the error handling more robust.The error handling implementation is good, but could be made more resilient with a few improvements:
Consider applying these improvements:
return this.apiService.get(`/orgs/${this.orgId}/travelperk/`, {}).pipe( catchError(error => { - if (error.status === 400 && error.error?.message?.includes('token expired')) { + // Define error interface for better type safety + interface TravelperkError { + status: number; + error?: { + message?: string; + is_expired?: boolean; + }; + } + + // Use constant for error message + const TOKEN_EXPIRED_MESSAGE = 'token expired'; + + // Safer error handling with type checking + if (error?.status === 400 && + typeof error?.error?.message === 'string' && + error.error.message.includes(TOKEN_EXPIRED_MESSAGE)) { error.error.is_expired = true; } return throwError(() => error); }) );This refactor:
- Adds type safety with an interface
- Makes error property checks more defensive
- Extracts the error message to a constant
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/app/core/services/travelperk/travelperk.service.ts
(2 hunks)
🔇 Additional comments (2)
src/app/core/services/travelperk/travelperk.service.ts (2)
2-2
: LGTM!
The necessary RxJS operators are correctly imported for the error handling implementation.
33-40
: Verify error handling in consuming components.
Let's ensure that components using this service properly handle the is_expired
flag.
✅ Verification successful
Let me generate new shell scripts to better analyze the error handling patterns.
Error handling for token expiration is properly implemented
The codebase shows comprehensive error handling for TravelPerk token expiration:
- The
TravelperkTokenGuard
properly handles the 400 status error, shows an expiration message, and redirects users to the onboarding landing page - The service correctly sets
is_expired = true
flag when token expiration is detected - Components using
getTravelperkData()
have error handlers in place that handle failed requests
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for usages of getTravelperkData to verify error handling
echo "Searching for getTravelperkData usage:"
rg -A 10 "getTravelperkData\(\)" --type ts
# Search for error handling patterns in components
echo "Checking error handling patterns in components:"
ast-grep --pattern 'catchError($_)' --type ts
Length of output: 8495
Script:
#!/bin/bash
# Search for error handling in components that use getTravelperkData
echo "Searching for error handling in TravelPerk components:"
rg -B 5 -A 10 "error\." "src/app/integrations/travelperk/"
# Search specifically for is_expired handling
echo "Searching for is_expired handling:"
rg "is_expired" --type ts
# Check error handling in the guard
echo "Checking TravelPerk guard implementation:"
cat src/app/core/guard/travelperk-token.guard.ts
Length of output: 6734
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (1)
src/app/core/guard/travelperk-token.guard.ts (1)
1-9
: Consider creating route constantsThe navigation URL 'integrations/travelperk/onboarding/landing' is hardcoded. Consider moving it to a constants file for better maintainability.
// src/app/core/constants/routes.constant.ts export const TRAVELPERK_ROUTES = { ONBOARDING_LANDING: 'integrations/travelperk/onboarding/landing' } as const;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/app/core/guard/travelperk-token.guard.ts
(1 hunks)src/app/core/services/travelperk/travelperk.service.ts
(2 hunks)src/app/integrations/qbo/qbo-main/qbo-mapping/qbo-mapping.component.spec.ts
(2 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/app/core/services/travelperk/travelperk.service.ts
[error] 43-43: Don't use '{}' as a type.
Prefer explicitly define the object shape. '{}' means "any non-nullable value".
(lint/complexity/noBannedTypes)
🔇 Additional comments (1)
src/app/integrations/qbo/qbo-main/qbo-mapping/qbo-mapping.component.spec.ts (1)
Line range hint 97-141
: Verify intention behind skipped tests
Two tests related to branding case styles are currently skipped. Please clarify if these tests are:
- Temporarily skipped due to pending implementation
- No longer relevant and should be removed
- Failing and need fixes
canActivate( | ||
route: ActivatedRouteSnapshot, | ||
state: RouterStateSnapshot | ||
): Observable<boolean> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add return type for getTravelperkTokenHealth response
The service method's response type is {}
. Consider creating an interface for better type safety.
// src/app/core/models/travelperk/travelperk.model.ts
export interface TravelperkTokenHealth {
is_healthy: boolean;
}
canActivate( | ||
route: ActivatedRouteSnapshot, | ||
state: RouterStateSnapshot | ||
): Observable<boolean> { | ||
return this.travelperkService.getTravelperkTokenHealth().pipe( | ||
map(() => true), | ||
catchError(error => { | ||
if (error.status === 400) { | ||
globalCacheBusterNotifier.next(); | ||
this.toastService.displayToastMessage(ToastSeverity.ERROR, 'Oops! Your TravelPerk connection expired, please connect again'); | ||
this.router.navigateByUrl('integrations/travelperk/onboarding/landing'); | ||
} | ||
return throwError(() => error); | ||
}) | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Enhance error handling to cover all failure scenarios
The current implementation only handles 400 status explicitly, but other error scenarios (like network issues, 500s) should also be handled gracefully.
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
): Observable<boolean> {
return this.travelperkService.getTravelperkTokenHealth().pipe(
map(() => true),
catchError(error => {
- if (error.status === 400) {
+ if (error.status === 400 && error.error?.is_expired) {
globalCacheBusterNotifier.next();
this.toastService.displayToastMessage(ToastSeverity.ERROR, 'Oops! Your TravelPerk connection expired, please connect again');
this.router.navigateByUrl('integrations/travelperk/onboarding/landing');
+ } else {
+ this.toastService.displayToastMessage(ToastSeverity.ERROR, 'Failed to verify TravelPerk connection');
}
return throwError(() => error);
})
);
}
Committable suggestion skipped: line range outside the PR's diff.
return this.apiService.get(`/orgs/${this.orgId}/travelperk/`, {}).pipe( | ||
catchError(error => { | ||
if (error.status === 400 && error.error?.message?.includes('token expired')) { | ||
error.error.is_expired = true; | ||
} | ||
return throwError(() => error); | ||
}) | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Extract error handling logic to a reusable operator
The error handling logic is duplicated between getTravelperkData
and getTravelperkTokenHealth
. Consider extracting it to a reusable operator.
private handleTravelperkError = () => <T>(source: Observable<T>): Observable<T> => {
return source.pipe(
catchError(error => {
if (error.status === 400) {
if (error.error?.message?.includes('token expired') || error.error?.is_expired) {
error.error.is_expired = true;
}
}
return throwError(() => error);
})
);
};
// Usage:
getTravelperkData(): Observable<Travelperk> {
return this.apiService.get(`/orgs/${this.orgId}/travelperk/`, {}).pipe(
this.handleTravelperkError()
);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (2)
src/app/core/services/travelperk/travelperk.service.ts (2)
33-41
: 🛠️ Refactor suggestionExtract duplicated error handling logic
The error handling logic is duplicated between this method and getTravelperkTokenHealth.
Previous review suggested extracting this to a reusable operator, which is still applicable:
private handleTravelperkError = () => <T>(source: Observable<T>): Observable<T> => { return source.pipe( catchError(error => { if (error.status === 400) { if (error.error?.message?.includes('token expired') || error.error?.is_expired) { error.error.is_expired = true; } } return throwError(() => error); }) ); };
44-44
: 🛠️ Refactor suggestionDefine proper interface for token health response
Using
{}
as return type isn't type-safe and could lead to runtime errors.Create and use a proper interface:
interface TravelperkTokenHealth { is_healthy: boolean; // add other relevant fields }🧰 Tools
🪛 Biome (1.9.4)
[error] 44-44: Don't use '{}' as a type.
Prefer explicitly define the object shape. '{}' means "any non-nullable value".
(lint/complexity/noBannedTypes)
🧹 Nitpick comments (2)
src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.ts (1)
485-486
: Improve readability & address lint warningsThe current arrow function body can be simplified and reformatted to address lint warnings related to curly braces and spacing. Consider returning the observable directly:
- this.workspaceService.getWorkspaceGeneralSettings().pipe(catchError(error => {return of(null);})), + this.workspaceService.getWorkspaceGeneralSettings().pipe( + catchError(() => of(null)) + ),🧰 Tools
🪛 GitHub Check: lint
[failure] 485-485:
Statement inside of curly braces should be on next line
[failure] 485-485:
Requires a space after '{'
[failure] 485-485:
Closing curly brace should be on the same line as opening curly brace or on the line after the previous block
[failure] 485-485:
Requires a space before '}'src/app/core/services/travelperk/travelperk.service.ts (1)
43-43
: Review caching strategy for token healthThe @Cacheable decorator is used without a cache buster. Consider:
- Adding a cache buster for token health
- Setting an appropriate TTL for the cache
Example implementation:
const tokenHealthCache$ = new Subject<void>(); @Cacheable({ cacheBusterObserver: tokenHealthCache$, maxAge: 5 * 60 * 1000 // 5 minutes })
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/app/core/services/travelperk/travelperk.service.ts
(2 hunks)src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.ts
(2 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/app/core/services/travelperk/travelperk.service.ts
[error] 44-44: Don't use '{}' as a type.
Prefer explicitly define the object shape. '{}' means "any non-nullable value".
(lint/complexity/noBannedTypes)
🪛 GitHub Check: lint
src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.ts
[failure] 485-485:
Statement inside of curly braces should be on next line
[failure] 485-485:
Requires a space after '{'
[failure] 485-485:
Closing curly brace should be on the same line as opening curly brace or on the line after the previous block
[failure] 485-485:
Requires a space before '}'
🔇 Additional comments (2)
src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.ts (1)
4-4
: Nice addition of error handling importsThe addition of
catchError
andof
from RxJS is a good practice for gracefully handling and recovering from observable errors.src/app/core/services/travelperk/travelperk.service.ts (1)
2-2
: LGTM: Required imports added correctlyThe necessary RxJS operators for error handling have been properly imported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.ts (1)
485-486
: Consider logging workspace settings retrieval failuresThe error handling for workspace settings is good as it prevents the observable chain from breaking. However, consider logging the error for debugging purposes. Also, the code properly handles null cases by providing default values:
employeeFieldMapping
defaults toEmployeeFieldMapping.EMPLOYEE
isImportItemsEnabled
defaults tofalse
auto_map_employees
defaults tofalse
this.workspaceService.getWorkspaceGeneralSettings().pipe( catchError(error => { + console.error('Failed to fetch workspace settings:', error); return of(null); }) ),
Also applies to: 491-491, 499-499, 508-508
🧰 Tools
🪛 eslint
[error] 485-485: Statement inside of curly braces should be on next line.
(brace-style)
[error] 485-485: Requires a space after '{'.
(block-spacing)
[error] 485-485: Closing curly brace should be on the same line as opening curly brace or on the line after the previous block.
(brace-style)
[error] 485-485: Requires a space before '}'.
(block-spacing)
🪛 GitHub Check: lint
[failure] 485-485:
Statement inside of curly braces should be on next line
[failure] 485-485:
Requires a space after '{'
[failure] 485-485:
Closing curly brace should be on the same line as opening curly brace or on the line after the previous block
[failure] 485-485:
Requires a space before '}'
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.ts
(3 hunks)
🧰 Additional context used
🪛 eslint
src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.ts
[error] 485-485: Statement inside of curly braces should be on next line.
(brace-style)
[error] 485-485: Requires a space after '{'.
(block-spacing)
[error] 485-485: Closing curly brace should be on the same line as opening curly brace or on the line after the previous block.
(brace-style)
[error] 485-485: Requires a space before '}'.
(block-spacing)
🪛 GitHub Check: lint
src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.ts
[failure] 485-485:
Statement inside of curly braces should be on next line
[failure] 485-485:
Requires a space after '{'
[failure] 485-485:
Closing curly brace should be on the same line as opening curly brace or on the line after the previous block
[failure] 485-485:
Requires a space before '}'
🔇 Additional comments (1)
src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.ts (1)
491-491
: LGTM: Robust default value handlingThe code properly handles potential null/undefined workspace settings by providing sensible default values using the nullish coalescing operator. This makes the component more resilient to API failures.
Also applies to: 499-499, 508-508
this.workspaceService.getWorkspaceGeneralSettings().pipe(catchError(error => {return of(null);})), | ||
this.employeeSettingService.getDistinctQBODestinationAttributes([FyleField.EMPLOYEE, FyleField.VENDOR]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Fix the formatting of error handling code block
The error handling code block has formatting issues. Apply proper spacing and line breaks for better readability.
- this.workspaceService.getWorkspaceGeneralSettings().pipe(catchError(error => {return of(null);})),
+ this.workspaceService.getWorkspaceGeneralSettings().pipe(
+ catchError(error => {
+ return of(null);
+ })
+ ),
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
this.workspaceService.getWorkspaceGeneralSettings().pipe(catchError(error => {return of(null);})), | |
this.employeeSettingService.getDistinctQBODestinationAttributes([FyleField.EMPLOYEE, FyleField.VENDOR]), | |
this.workspaceService.getWorkspaceGeneralSettings().pipe( | |
catchError(error => { | |
return of(null); | |
}) | |
), | |
this.employeeSettingService.getDistinctQBODestinationAttributes([FyleField.EMPLOYEE, FyleField.VENDOR]), |
🧰 Tools
🪛 eslint
[error] 485-485: Statement inside of curly braces should be on next line.
(brace-style)
[error] 485-485: Requires a space after '{'.
(block-spacing)
[error] 485-485: Closing curly brace should be on the same line as opening curly brace or on the line after the previous block.
(brace-style)
[error] 485-485: Requires a space before '}'.
(block-spacing)
🪛 GitHub Check: lint
[failure] 485-485:
Statement inside of curly braces should be on next line
[failure] 485-485:
Requires a space after '{'
[failure] 485-485:
Closing curly brace should be on the same line as opening curly brace or on the line after the previous block
[failure] 485-485:
Requires a space before '}'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.spec.ts (1)
518-518
: Consider re-enabling this skipped test to maintain coverage and detect potential regressions.
Skipping this important test may reduce confidence in the CCC expense grouping logic.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.spec.ts
(1 hunks)src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.ts
(3 hunks)
🔇 Additional comments (6)
src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.ts (6)
4-4
: AddingcatchError
to the imports looks good.
This import strengthens error-handling capabilities.
485-487
: Fix the formatting of the error handling code block.
This comment has been flagged before in a past review; the block lacks spacing and line breaks, making it harder to read.485 this.workspaceService.getWorkspaceGeneralSettings().pipe(catchError(error => { - return of(null); + return of(null); }))
488-488
: No issues found with addingemployeeSettingService.getDistinctQBODestinationAttributes
to forkJoin.
Good use of combining multiple observables.
493-493
: Providing a default fallback foremployee_field_mapping
is a robust approach.
Ensures the component remains stable if this field is missing in the settings.
510-510
: A defaultfalse
forauto_map_employees
is sensible if the property is undefined.
This patch ensures that the employee mapping form remains safe if no value is provided.
501-501
: Verifying defaultingisImportItemsEnabled
to false.
Confirm that disabling item imports by default won’t cause unexpected behavior for workspaces intended to use item imports.✅ Verification successful
Defaulting
isImportItemsEnabled
to false is safe and consistent with the codebaseBased on the codebase analysis:
- The
isImportItemsEnabled
flag is consistently initialized fromworkspaceGeneralSettings.import_items
- The only conditional behavior dependent on this flag is:
- Displaying additional warning content when switching to JOURNAL_ENTRY export type
- Adjusting display names in the dashboard error section to include "Item" alongside "Account"
- The default
false
value is already used in story files, indicating it's an expected default state- No code paths assume or require this flag to be true by default
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Confirm if any references assume `isImportItemsEnabled` is true by default. rg -A 2 "isImportItemsEnabled"Length of output: 7807
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/app/core/models/qbo/qbo-configuration/qbo-export-setting.model.ts (1)
261-261
: Consider extracting fallback logic to a helper function for consistency.Using a conditional access operator here ensures null safety, preventing potential runtime errors. For maintainability, you might extract the fallback logic to a helper function or a common config, making it easier to manage the default behavior across the codebase.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/app/core/models/qbo/qbo-configuration/qbo-export-setting.model.ts
(1 hunks)src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.ts
(5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.ts
|
* feat: Travelperk Guard * lint fix * token guard * lint fix * fix * pr comments * make cacheable and catch error * lint fix * fixes for export settings wgs * fix lint * minor fixes for wgs * fix tests * skip flaky
Description
Clickup
Summary by CodeRabbit
New Features
TravelperkTokenGuard
to manage route access based on TravelPerk token health.payment_profile_settings
,advanced_settings
, anddone
routes.QboExportSettingsComponent
for fetching workspace general settings.Bug Fixes
getTravelperkData
andgetTravelperkTokenHealth
methods.QBOExportSettingModel
to prevent runtime errors.Tests
QboMappingComponent
with new expected values and skipped specific test cases.QboExportSettingsComponent
, marking a test as skipped and adjusting mock service setups.